<template>
  <page-header-wrapper :title="false">
    <a-card title="商标库管理">
      <template slot="extra">
        <a-button icon="plus" type="primary" @click="$router.push({ name: 'AddResource' })">添加商标</a-button>
      </template>
      <a-tabs v-model="tab" type="card">
        <a-tab-pane key="1" tab="全部商标"></a-tab-pane>
        <a-tab-pane key="2" tab="在售商标"></a-tab-pane>
        <a-tab-pane key="3" tab="已售商标"></a-tab-pane>
        <a-tab-pane key="4" tab="下架商标"></a-tab-pane>
      </a-tabs>
      <div class="table-page-search-wrapper">
        <a-form-model
          layout="inline"
          :model="queryParam"
        >
          <a-row :gutter="15">
            <a-col :md="6" :sm="24">
              <a-form-model-item label="商标名称">
                <a-input v-model="queryParam['filter[zl_name]']" />
              </a-form-model-item>
            </a-col>
            <a-col :md="6" :sm="24">
              <a-form-model-item label="注册号">
                <a-input v-model="queryParam['filter[phone]']" />
              </a-form-model-item>
            </a-col>
            <template v-if="advanced">
              <a-col :md="6" :sm="24">
                <a-form-model-item label="申请人">
                  <a-select v-model="queryParam['filter[customer_status]']" :default-value="0">
                  </a-select>
                </a-form-model-item>
              </a-col>
              <a-col :md="6" :sm="24">
                <a-form-item label="商标类别">
                  <a-select v-model="queryParam['filter[customer_status]']" :default-value="0">
                  </a-select>
                </a-form-item>
              </a-col>
              <a-col :md="6" :sm="24">
                <a-form-item label="注册日期">
                  <a-range-picker />
                </a-form-item>
              </a-col>
              <a-col :md="6" :sm="24">
                <a-form-item label="资源类型">
                  <a-select v-model="queryParam['filter[customer_status]']" :default-value="0">
                  </a-select>
                </a-form-item>
              </a-col>
            </template>
            <a-col :md="!advanced && 8 || 24" :sm="24">
                <span class='table-page-search-submitButtons' :style="advanced && { float: 'right', overflow: 'hidden' } || {} ">
                  <a-button type="primary" @click="$refs.table.refresh(true)">搜索</a-button>
                  <a-button style="margin-left: 8px" @click="resetForm">重置</a-button>
                  <a @click="toggleAdvanced" style="margin-left: 8px">
                    {{ advanced ? '收起' : '展开' }}
                    <a-icon :type="advanced ? 'up' : 'down'" />
                  </a>
                </span>
            </a-col>
          </a-row>
        </a-form-model>
      </div>
      <div class="table-operator">
        <s-table
          bordered
          size="middle"
          ref="table"
          :row-key="(record) => record.id"
          :columns="resourceColumns"
          :data="resourceData"
        >
          <template slot="trademark_img" slot-scope="text">
            <img width="40" height="40" :src="text" />
          </template>
          <template slot="action">
            <a-button size="small" type="primary" @click="toDetail">详情</a-button>
            <a-button size="small" v-if="tab == 2" type="danger">下架</a-button>
            <a-button size="small" v-if="tab == 4" type="danger">上架</a-button>
          </template>
        </s-table>
      </div>
    </a-card>
  </page-header-wrapper>
</template>

<script>
import { STable } from '@/components'
import resourceColumns from '@/columns/common.resource'

export default {
  components: {
    STable
  },
  name: 'ResourceList',
  data () {
    return {
      tab: '1',
      resourceColumns: resourceColumns.list,
      resourceData: () => {
        return new Promise(resolve => {
          resolve({
            page: 1,
            total_count: 2,
            page_size: 10,
            data: [
              {
                id: 1,
                trademark_img: 'https://tm-data.oss-cn-beijing.aliyuncs.com/tm_img/2009/9/7698078.jpg?Expires=1634025403&OSSAccessKeyId=hObpgEXoca42qH3V&Signature=%2BuMaOkSdD95jE2CiuwwD7VIKAIM%3D',
                resource_type: '公司注册',
                tm_reg_no: '20200205',
                tm_name: '天猫',
                category: '第25类',
                created_at: '2010-04-01',
                price: '50000.00',
                register: '北京鑫彭知识产权代理有限公司'
              },
              {
                id: 2,
                resource_type: '其他平台',
                tm_reg_no: '20200205',
                tm_name: '马婷',
                category: '第45类',
                created_at: '2010-04-01',
                price: '3500.00',
                register: '北京京标知识产权代理有限公司'
              }
            ]
          })
        })
      },
      advanced: false,
      queryParam: {}
    }
  },
  methods: {
    toDetail () {
      this.$router.push({ name: 'ResourceDetail' })
    },
    toggleAdvanced () {
      this.advanced = !this.advanced
    },
    resetForm () {
      this.queryParam = {}
    }
  }
}
</script>

<style scoped>

</style>
